{% extends 'core/base.html' %}
{% block content %}
<div class="favorites-container">
    <h2>我的收藏</h2>

    {% if favorites %}
        <div class="favorites-grid">
            {% for fav in favorites %}
                <div class="favorite-card">
                    <div class="favorite-content">
                        <h3 class="favorite-name">{{ fav.trash_item.name }}</h3>
                        <div class="favorite-category">{{ fav.trash_item.category }}</div>
                    </div>
                    <div class="favorite-actions">
                        <a href="{% url 'trash_detail' fav.trash_item.id %}" class="view-details-btn">
                            查看详情
                        </a>
                    </div>
                </div>
            {% endfor %}
        </div>
    {% else %}
        <div class="empty-favorites">
            <div class="empty-icon">⭐</div>
            <p>你还没有收藏任何垃圾条目。</p>
            <a href="{% url 'search' %}?q=" class="btn">开始查询并收藏</a>
        </div>
    {% endif %}
</div>

<style>
    .favorites-container {
        max-width: 1000px;
        margin: 0 auto;
    }

    .favorites-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
        margin-top: 2rem;
    }

    .favorite-card {
        background-color: white;
        border-radius: 10px;
        box-shadow: 0 3px 15px rgba(0,0,0,0.1);
        padding: 1.5rem;
        transition: transform 0.3s, box-shadow 0.3s;
        display: flex;
        flex-direction: column;
    }

    .favorite-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    }

    .favorite-content {
        flex-grow: 1;
    }

    .favorite-name {
        color: var(--primary-dark);
        margin-top: 0;
        margin-bottom: 1rem;
        font-size: 1.3rem;
    }

    .favorite-category {
        display: inline-block;
        background-color: var(--primary);
        color: white;
        padding: 5px 12px;
        border-radius: 20px;
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    .favorite-actions {
        margin-top: auto;
        text-align: center;
    }

    .view-details-btn {
        display: inline-block;
        background-color: var(--secondary);
        color: white;
        padding: 8px 20px;
        border-radius: 5px;
        text-decoration: none;
        transition: background-color 0.3s;
        width: 100%;
    }

    .view-details-btn:hover {
        background-color: #1976D2;
        text-decoration: none;
    }

    .empty-favorites {
        text-align: center;
        padding: 3rem 1rem;
        background-color: #f5f5f5;
        border-radius: 10px;
        margin-top: 2rem;
    }

    .empty-icon {
        font-size: 3rem;
        margin-bottom: 1rem;
    }

    .empty-favorites p {
        margin-bottom: 1.5rem;
        color: var(--text-light);
    }

    @media (max-width: 768px) {
        .favorites-grid {
            grid-template-columns: 1fr;
        }
    }
</style>
{% endblock %}